package org.rambadger.command.event;

import org.rambadger.command.validation.UrlIdentifier;

import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * Event representing an {@link org.rambadger.command.model.AssignmentEntity Assignment} being removed from a {@link org.rambadger.command.model.TrackEntity Track}
 *
 * @see AssignmentAddedToTrack
 */
public class AssignmentRemovedFromTrack implements Serializable {
    private static final long serialVersionUID = 8514299472443806832L;

    //Compound Key {
    private final String platformId;
    private final String assignmentId;
    //}
    //Compound Key {
    //private final String platformId;
    private final String trackId;
    //}

    /**
     * Instantiates a new event
     *
     * @param platformId the platform id
     * @param assignmentId the assignment id
     * @param trackId the track id
     */
    public AssignmentRemovedFromTrack(String platformId, String assignmentId, String trackId) {
        this.platformId = platformId;
        this.assignmentId = assignmentId;
        this.trackId = trackId;
    }

    /**
     * Gets the identifier of the platform that the assignment and track belong to.
     *
     * @return the platform id
     */
    @UrlIdentifier @NotNull
    public String getPlatformId() {
        return platformId;
    }

    /**
     * Gets the identifier of the assignment that was removed the track.
     *
     * @return the assignment id
     */
    @UrlIdentifier @NotNull
    public String getAssignmentId() {
        return assignmentId;
    }

    /**
     * Gets the identifier of the track that the assignment was removed from.
     *
     * @return the track id
     */
    @UrlIdentifier
    @NotNull
    public String getTrackId() {
        return trackId;
    }

    public String getFullAssignmentId() {
        return platformId+"/"+assignmentId;
    }

    public String getFullTrackId() {
        return platformId+"/"+trackId;
    }

    @Override
    public String toString() {
        return "AssignmentRemovedFromTrack{" +
                "platformId='" + platformId + '\'' +
                ", assignmentId='" + assignmentId + '\'' +
                ", trackId='" + trackId + '\'' +
                '}';
    }
}
